//
//  ZKcityModle.m
//  zkCityList
//
//  Created by 帮友贷 on 16/3/1.
//  Copyright © 2016年 帮友贷. All rights reserved.
//

#import "ZKcityModle.h"
#import "ZKCity.h"
@implementation ZKcityModle

-(instancetype)initWithDict:(NSDictionary *)dict
{
    self = [super init];
    if (self) {
        [self setValue:dict[@"initial"] forKey:@"titleName"];
        
        self.citys = [ZKCity cityWithArray:dict[@"citys"]];
    }
    
    return self;
}

+ (instancetype)cityGroupWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

+ (NSArray *)cityGroups
{
    NSArray *array = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"CityData.plist" ofType:nil]];
    
    NSMutableArray *arrayM = [NSMutableArray array];
    for (NSDictionary *dict in array) {
        [arrayM addObject:[self cityGroupWithDict:dict]];
    }
    
    return arrayM;
}

- (NSString *)description
{
    return [NSString stringWithFormat:@"<%@: %p> {title: %@, citys: %@}", self.class, self, self.titleName, self.citys];
}

@end
